<template>
  <el-card>
    <template #header>
      <div class="clearfix">
        <span>用户列表</span>
        <el-button @click="router.push('/home/system/user/add')" style="float: right; padding: 3px 0" type="text">添加</el-button>
      </div>
    </template>
    <el-table :data="users" >
      <el-table-column type="selection" width="55" />
      <el-table-column prop="id" label="ID" width="100"></el-table-column>
      <el-table-column prop="username" label="用户名" align="center"></el-table-column>
      <el-table-column prop="password" label="密码" align="center"></el-table-column>
    </el-table>
  </el-card>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { fetchUserList } from "../../../../api/UserApi.ts";
import router from "../../../../router";

const users = ref([]);

const fetchUsers = async () => {
  const res = await fetchUserList();
  if (res.code === 200) {
    users.value = res.data
  }
};


fetchUsers();

</script>

<style scoped>
.el-card {
  margin-top: 20px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 0 #ffffff;
  outline: 0;
}
</style>
